﻿using System;
using System.ComponentModel;

namespace RLProject1.ViewModel {

    public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable {

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion


        protected ViewModelBase(){ }


        #region IDisposable Members

        public void Dispose() {
            this.OnDispose();
        }

        /// <summary>
        /// Override this method to handle a call of Dispose.
        /// </summary>
        protected virtual void OnDispose() {
        }

        #endregion

        /// <summary>
        /// Fires PropertyChange Event. You might override this method, if you want additional handling.
        /// </summary>
        /// <param name="propertyName"></param>
        protected virtual void OnPropertyChanged(String propertyName) {
            if(PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        
    }
}
